﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MasterPagePrivate.master" ValidateRequest="false" 
    AutoEventWireup="true" CodeFile="CompanyProfileEdit.aspx.cs" Inherits="Pages_Private_CompanyProfileEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageHeader" Runat="Server">
    <script language="javascript" type="text/javascript">
        function ValidateBillingRequired(sender, args) {
            if (args.Value.length > 0)
                args.IsValid = true;
            else
                args.IsValid = false;
        }
        function ValidatePhoneNo(sender, args)
        {
            if (args.Value.indexOf(',') > -1)
                args.IsValid = false;
            else
                args.IsValid = true;
        }


        var _CountryIDOfBangladesh = <%= ConfigReader.CountryIDOfBangladesh %>;

        function ValidateCitySelection(sender, args) {
            var ddlPreferredCountry = $('#<%= ddlCountry.ClientID %>').val();            
            if(ddlPreferredCountry==_CountryIDOfBangladesh){
                var city = $('#<%= ddlCityID.ClientID %>').val();                
                if(city==''||city==undefined||city==null) 
                    args.IsValid = false;
                else
                    args.IsValid = true;
            }else{
                var city2 = $('#<%= txtCityName.ClientID %>').val();                
                if(city2==''||city2==undefined||city2==null) 
                    args.IsValid = false;
                else
                    args.IsValid = true;
            }
                
        }

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="PageBody" Runat="Server">
    <h4 id="h4Heading" runat="server">Edit Company Profile</h4>
    <div id="divMessage" runat="server" visible="false" enableviewstate="false"></div>

    <asp:Panel ID="pnlFormContainer" runat="server" DefaultButton="btnSave">
        <div class="WizardContainer">
            <div class="StepHeaderContainer">
                <div class="StepHeading">
                    <asp:Label ID="lblMemberShipType" runat="server" Text="Company Profile"></asp:Label>
                </div>
                <div class="StepSubHeading"><asp:Label ID="Label1" runat="server" Text="Define Your Company Profile"></asp:Label></div>
            </div>
            <div class="StepBody">
                <table cellpadding="3" cellspacing="0" style="width:100%;">
                    <colgroup>
                        <col style="width:20%;" />
                        <col />
                    </colgroup>
                    <tr>
                        <td><asp:Label ID="lblCompanyName" runat="server" Text="Company Name"></asp:Label><span class="requiredMark">*</span></td>
                        <td>
                            <asp:TextBox ID="txtCompanyName" runat="server" MaxLength="150"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
							    ControlToValidate="txtCompanyName" SetFocusOnError="true"
							    ErrorMessage="Please enter Your Company Name." Display="Dynamic"
							    ValidationGroup="SaveInfo">
						    </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>

                <div>
                    <div class="GroupBox">
                        <div class="GroupHeaderOverlay">Company Address</div>
                        <table cellpadding="3" cellspacing="0" style="width:50%;">
                            <colgroup>
                                <col style="width:38%;" />
                                <col />                                        
                            </colgroup>	
                            <tbody>
				                <tr>
					                <td><asp:Label ID="lblCountry" runat="server" Text="Country"></asp:Label><span class="requiredMark">*</span></td>
					                <td>
						                <asp:DropDownList ID="ddlCountry" runat="server" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
						                <asp:RequiredFieldValidator ID="rfvCountry" runat="server"
							                ControlToValidate="ddlCountry" SetFocusOnError="true"
							                ErrorMessage="Please Select a Country." Display="Dynamic"
							                ValidationGroup="SaveInfo">
						                </asp:RequiredFieldValidator>
					                </td>
				                </tr>
                                <tr runat="server" Visible="false" id="cityForNonBD">
                                    <td>City<span class="requiredMark">*</span></td>
                                    <td>
                                        <asp:TextBox ID="txtCityName" runat="server" MaxLength="200"></asp:TextBox>
                                        <asp:CustomValidator ID="rfvCityName" runat="server"
                                            Display="Dynamic" SetFocusOnError="true" ClientValidationFunction="ValidateCitySelection" 
                                            ValidationGroup="SaveInfo" ValidateEmptyText="true"
                                            ErrorMessage="Please enter your City.">
                                        </asp:CustomValidator>
                                    </td>                            
                                </tr>
                                
                                <tr id="cityForBD" runat="server" Visible="true">
					                <td>City<span class="requiredMark">*</span></td>
					                <td>
						                <asp:DropDownList ID="ddlCityID" runat="server"></asp:DropDownList>
						                <asp:CustomValidator ID="rfvCity" runat="server"
                                            Display="Dynamic" SetFocusOnError="true" ClientValidationFunction="ValidateCitySelection" 
                                            ValidationGroup="SaveInfo" ValidateEmptyText="true"
                                            ErrorMessage="Please select your City.">
                                        </asp:CustomValidator>
					                </td>
				                </tr>

				                <tr>
					                <td>Street Address</td>
					                <td>
						                <asp:TextBox ID="txtStreetAddress" MaxLength="150" runat="server"></asp:TextBox>
					                </td>
				                </tr>
				                <tr>
					                <td>Zip Code</td>
					                <td>
						                <asp:TextBox ID="txtZipCode" MaxLength="50" runat="server"></asp:TextBox>
					                </td>
				                </tr>
                            </tbody>		        
                            <tbody id="tbdPhoneContainer">
				                <tr>
					                <td>Phone 1</td>
					                <td>
						                <asp:TextBox ID="txtPhone1" MaxLength="15" runat="server"></asp:TextBox>
                                        <asp:CustomValidator ID="cvPhone1" runat="server"
                                            Display="Dynamic" SetFocusOnError="true"
                                            ControlToValidate="txtPhone1"
                                            ClientValidationFunction="ValidatePhoneNo"
                                            ErrorMessage="Enter a Valid Phone Number."
                                            ValidationGroup="SaveInfo">
                                        </asp:CustomValidator>
					                </td>
				                </tr>
                                <tr>
					                <td>Phone 2</td>
					                <td>
						                <asp:TextBox ID="txtPhone2" MaxLength="15" runat="server"></asp:TextBox>
                                        <asp:CustomValidator ID="CustomValidator1" runat="server"
                                            Display="Dynamic" SetFocusOnError="true"
                                            ControlToValidate="txtPhone2"
                                            ClientValidationFunction="ValidatePhoneNo"
                                            ErrorMessage="Enter a Valid Phone Number."
                                            ValidationGroup="SaveInfo">
                                        </asp:CustomValidator>
					                </td>
				                </tr>
                                <tr>
					                <td>Phone 3</td>
					                <td>
						                <asp:TextBox ID="txtPhone3" MaxLength="15" runat="server"></asp:TextBox>
                                        <asp:CustomValidator ID="CustomValidator2" runat="server"
                                            Display="Dynamic" SetFocusOnError="true"
                                            ControlToValidate="txtPhone3"
                                            ClientValidationFunction="ValidatePhoneNo"
                                            ErrorMessage="Enter a Valid Phone Number."
                                            ValidationGroup="SaveInfo">
                                        </asp:CustomValidator>
					                </td>
				                </tr>				                                          
                            </tbody>

                            <tbody>
				                <tr>
					                <td>Fax</td>
					                <td>
						                <asp:TextBox ID="txtFax" MaxLength="50" runat="server"></asp:TextBox>
					                </td>
				                </tr>
				                <tr>
					                <td>Email</td>
					                <td>
						                <asp:TextBox ID="txtEmail" MaxLength="50" runat="server"></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                            ControlToValidate="txtEmail" Display="Dynamic" SetFocusOnError="true"
                                            ErrorMessage="Please enter a valid Email address."
                                            ValidationGroup="SaveInfo">
                                        </asp:RegularExpressionValidator>
                                        <asp:CustomValidator ID="cvCompanyEmail" runat="server"
							                ControlToValidate="txtEmail" 
                                            OnServerValidate="cvCompanyEmail_ServerValidate"
                                            SetFocusOnError="true"
							                ErrorMessage="This Email is already taken please choose another." 
                                            Display="Dynamic"
							                ValidationGroup="SaveInfo">
						                </asp:CustomValidator>
					                </td>
				                </tr> 
                            </tbody>                           			            				                            
                        </table>
                    </div>
                    <%--
                    <div class="GroupBox" style="width:46%; float:right;">
                        <div class="GroupHeaderOverlay">Billing Address</div>
                        <table id="tblBillingAddress" cellpadding="3" cellspacing="0" style="width:100%;">
                            <colgroup>
                                <col style="width:35%;" />
                                <col />                                        
                            </colgroup>
                            <tr>
					            <td colspan="2"><asp:CheckBox ID="chkIsBillingAddress" runat="server" Checked="true" Text="Same as Company Address" /></td>					            
				            </tr>			        
				            <tr>
					            <td><asp:Label ID="lblBillingCountry" runat="server" Text="Country"></asp:Label><span class="requiredMark">*</span></td>
					            <td>
						            <asp:DropDownList ID="ddlBillingCountry" runat="server" OnSelectedIndexChanged="ddlBillingCountry_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
						            <asp:CustomValidator ID="RequiredFieldValidator2" runat="server"
							            ControlToValidate="ddlBillingCountry" ClientValidationFunction="ValidateBillingRequired" 
							            ErrorMessage="Please Select a Country." SetFocusOnError="true" Display="Dynamic"
							            ValidationGroup="SaveInfo">
						            </asp:CustomValidator>
					            </td>
				            </tr>
                            <tr>
					            <td>City<span class="requiredMark">*</span></td>
					            <td>
						            <asp:DropDownList ID="ddlBillingCity" runat="server"></asp:DropDownList>
						            <asp:CustomValidator ID="CustomValidator1" runat="server"
							            ControlToValidate="ddlBillingCity" ClientValidationFunction="ValidateBillingRequired" 
							            ErrorMessage="Please Select a City." SetFocusOnError="true" Display="Dynamic"
							            ValidationGroup="SaveInfo">
						            </asp:CustomValidator>
					            </td>
				            </tr>
				            <tr>
					            <td>Street Address</td>
					            <td>
						            <asp:TextBox ID="txtBillingStreetAddress" MaxLength="150" runat="server"></asp:TextBox>
					            </td>
				            </tr>
				            <tr>
					            <td>Zip Code</td>
					            <td>
						            <asp:TextBox ID="txtBillingZipCode" MaxLength="50" runat="server"></asp:TextBox>
					            </td>
				            </tr>
				            <tr>
					            <td>Phone</td>
					            <td>
						            <asp:TextBox ID="txtBillingPhone" MaxLength="50" runat="server"></asp:TextBox>
					            </td>
				            </tr>
				            <tr>
					            <td>Fax</td>
					            <td>
						            <asp:TextBox ID="txtBillingFax" MaxLength="50" runat="server"></asp:TextBox>
					            </td>
				            </tr>
				            <tr>
					            <td>Email</td>
					            <td>
						            <asp:TextBox ID="txtBillingEmail" MaxLength="50" runat="server"></asp:TextBox>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                        ControlToValidate="txtBillingEmail" Display="Dynamic" SetFocusOnError="true"
                                        ErrorMessage="Please enter a valid Email address."
                                        ValidationGroup="SaveInfo">
                                    </asp:RegularExpressionValidator>
					            </td>
				            </tr>                            				            				                            
                        </table>
                    </div>
                    --%>
                    <div class="clearboth"></div>
                </div>

                <table cellpadding="3" cellspacing="0" style="width:100%; margin-top:10px;">
                    <colgroup>
                        <col style="width:20%;" />
                        <col />
                    </colgroup>
                    <tr>
                        <td><asp:Label ID="lblCompanyLogo" runat="server" Text="Company Logo"></asp:Label></td>
                        <td>
                            <div>
                                <asp:Image CssClass="ProjectThumbImage" ID="imgCompanyLogo" runat="server" Visible="false" />
                            </div>
                            <div>
                                <asp:FileUpload CssClass="TextBoxCommon" ID="fuLogo" runat="server" />
                                <asp:CustomValidator ID="cvLogo" runat="server"
                                    ValidateEmptyText="true"
                                    Display="Dynamic" SetFocusOnError="true"
                                    ValidationGroup="SaveInfo" OnServerValidate="cvLogo_ServerValidate"
                                    ErrorMessage="Please select a valid Image file.">
                                </asp:CustomValidator> 
                            </div>
                        </td>
                    </tr>
                    <tr>
					    <td><asp:Label ID="lblWebSite" runat="server" Text="Web Site"></asp:Label></td>
					    <td>
						    <asp:TextBox ID="txtWebSite" MaxLength="250" runat="server"></asp:TextBox>                            
						    <asp:RegularExpressionValidator ID="rgvWebSite" runat="server"
							    ValidationExpression="(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?"
                                ControlToValidate="txtWebSite" 
                                SetFocusOnError="true" Display="Dynamic"
							    ErrorMessage="Please enter a Valid URL for Web Site." 
							    ValidationGroup="SaveInfo">
						    </asp:RegularExpressionValidator>
					    </td>
				    </tr>
                    <tr>
					    <td><asp:Label ID="lblAboutUs" runat="server" Text="About Your Company"></asp:Label></td>
					    <td>
						    <asp:TextBox ID="txtAboutUs" TextMode="MultiLine" MaxLength="8000" style="height:250px;" runat="server"></asp:TextBox>
						    <asp:RequiredFieldValidator ID="rfvAboutUs" runat="server"
							    ControlToValidate="txtAboutUs" SetFocusOnError="true"
							    ErrorMessage="Please enter About Us." Display="Dynamic"
							    ValidationGroup="SaveInfo">
						    </asp:RequiredFieldValidator>
					    </td>
				    </tr>				
                </table>

                <div class="GroupBox">
                    <div class="GroupHeaderOverlay">Contacts</div>
                    <asp:Repeater ID="rptContacts" runat="server">
                        <HeaderTemplate>
                            <table cellpadding="3" cellspacing="0" style="width:100%;">
                                <colgroup>
                                    <col />
                                    <col style="width:15%;"/>
                                    <col style="width:10%;"/>
                                </colgroup>                                
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <b>Name:</b> <%# DataBinder.Eval(Container.DataItem, "Name") %><br />
                                    <b>Designation:</b> <%# DataBinder.Eval(Container.DataItem, "Designation")%><br />
                                    <b>Phone:</b> <%# DataBinder.Eval(Container.DataItem, "Phone")%><br />
                                    <b>Fax:</b> <%# DataBinder.Eval(Container.DataItem, "Fax")%><br />
                                    <b>Email:</b> <%# DataBinder.Eval(Container.DataItem, "Email")%><br />
                                </td>
                                <td>
                                    <div class="floatright">                                        
                                        <%#GetPhotoUrl(DataBinder.Eval(Container.DataItem, "Photo"))%>
                                    </div>
                                    <div class="clearboth"></div>
                                </td>
                                <td style="text-align:center;">
                                    <a href="<%= AppConstants.Pages.CONTACT_CHANGE %>?ID=<%# DataBinder.Eval(Container.DataItem, "ID") %>">Edit</a>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </div>
            </div>
            <div class="StepButtonContainer">
                <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" ValidationGroup="SaveInfo" />
            </div>
        </div>
    </asp:Panel>
</asp:Content>
